﻿using System.Threading.RateLimiting;
using MeterReader.WebApi.Models;
using Microsoft.EntityFrameworkCore;

namespace MeterReader.WebApi.Services.Repositories
{
    public class ReadOldDbRepository : IReadRepository
    {
        private readonly OldDbContext _context;

        public ReadOldDbRepository(OldDbContext context)
        {
            _context = context;
        }

        public async Task<TMeter> ReadDataAsync(int num, CancellationToken cancellationToken)
        {
            return await _context.TMeters.OrderBy(t => t.Id).Skip(num-1).FirstOrDefaultAsync(cancellationToken) ?? new TMeter();
        }
    }
}
